home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000094_icon-group-sender _Fri Apr 22 11:36:51 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
3KB
Received: by cheltenham.cs.arizona.edu; Fri, 22 Apr 1994 12:34:52 MST
Date: Fri, 22 Apr 1994 11:36:51 -0500
From: John David Stone <stone@math.grin.edu>
Message-Id: <199404221636.LAA01303@russell.math.grin.edu>
To: janpeter@mpi.nl
Cc: icon-group@cs.arizona.edu
In-Reply-To: Jan Peter de Ruiter's message of Fri, 22 Apr 1994 13:06:56 +0100 <9404221206.AA25564@mpix10.mpi.kun.nl>
Subject: is this a bug?
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
Here's an excerpt from _The Icon Programming Language_, second
edition (pages 76-77), that explains what's going on:
-----------------------------------------------------------------------------
A structure value is reference (pointer) to an aggregate of values.
Furthermore, assignment copies the reference (pointer) but not the
aggregate of values to which it points. There are several consequences of
these properties of structures that may not be immediately obvious.
Consider
index := list(50, 0)
temp := index
temp[1] := 1
The assignment of the value of index to temp does not copy the 50 values
pointed to by the value of index. Instead, index and temp both point to
the _same_ aggregate of values. Therefore, the assignment of 1 to temp[1]
changes the contents of the list that temp and index share as their value.
The effect is as if
index[1] := 1
had been evaluated. ... Since assignment does not copy structures, the
result of an expression such as
L1 := L2 := list(i, 0)
is to assign the _same_list to both L1 and L2. Subsequently, assignment to
a position in L2 changes the value of that position in L1, and conversely.
Similarly, the effect of
L := list(3, list(5, 0))
is to assign the _same_ list of five values to each of the three values in
L.
-----------------------------------------------------------------------------
De Ruiter is running up against the same problem; he has the _same_
(initially empty) list as the default value throughout table T1.
Consequently, when a call to put modifies the value of this list, the
effect is to change every entry in the table (because there _is_ actually
only one "aggregate of values" on the other end of all the pointers).
------ John David Stone - Lecturer in Computer Science and Philosophy -----
-------------- Manager of the Mathematics Local-Area Network --------------
-------------- Grinnell College - Grinnell, Iowa 50112 - USA --------------
-------- stone@math.grin.edu - (515) 269-3181 - stone@grin1.bitnet --------